package generic;

import com.aop.config.AopConfig;
import com.aop.intel.Human;
import com.aop.intel.impl.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AopProxy {

    /**
     * Jdk 动态代理实现测试
     */
    @Test
    public void testProxy(){
        ApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
        Human human = context.getBean(Human.class);
        human.display();
        System.out.println(human.getClass().getSuperclass());
    }

    /**
     * CgLib 动态代理实现
     */
    @Test
    public void testCgLibProxy(){
        ApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
        Person person = context.getBean(Person.class);
        person.display();
        System.out.println(person.getClass().getSuperclass());
    }
}
